//
// Camera.cpp for bomberman in /home/lefebv_w//workspace/cpp/bomberman/tests/compil
// 
// Made by damien lefebvre
// Login   <lefebv_w@epitech.net>
// 
// Started on  Thu May  2 18:33:21 2013 damien lefebvre
// Last update Tue May 28 23:10:39 2013 damien lefebvre
//

#include	"Camera.hh"

Camera::Camera(void)
  :m_position(0.0f, 0.0f, 0.0f), m_rotation(0.0f, 0.0f, 0.0f), m_focus(0.0f, 0.0f, 0.0f)
{}

void	Camera::initialize(Vector3f const & startMap, float size_x, float size_y, float sizeBox)
{
  std::cout << "----- CAMERA LOADING -----" << std::endl;
  
m_focus.x = startMap.x + (size_x * sizeBox / 2); 
  m_focus.y = startMap.y + (size_y * sizeBox / 2); 
  m_focus.z = startMap.z; 
  m_position = m_focus;
  m_position.z = m_focus.z + CAMERA_TOP;

  std::cout << "camera position (" << m_position.x << ", " << m_position.y << ", " << m_position.z << ")" << std::endl;
  std::cout << "center of level (" << m_focus.x << ", " << m_focus.y << ", " << m_focus.z << ")" << std::endl;

  // config of camera's frustum
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(70.0f, 800.0f/600.0f, 1.0f, 10000.0f);
  gluLookAt(m_position.x, m_position.y, m_position.z,
	    m_focus.x, m_focus.y, m_focus.z,
	    1.0f, 0.0f, 0.0f);

  // set position of camera
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  // activate deep test
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  std::cout << "camera loaded" << std::endl;
}

void	Camera::update(gdl::GameClock const & gameClock, gdl::Input & input)
{}
